Method invocation for persistent objects with dynamic multikeys

ABSTRACT

A mechanism is disclosed that enables the invocation of methods of object instances that have persistent data and a mutable key. A mutable key capability is advantageous in a variety of applications, such as monitoring a set of users and their login status on a plurality of media servers (e.g., an email server, an instant messaging server, a voice mail server, a video server, an audio-conferencing server, etc.). The methods that can be invoked include get methods, set methods, unset methods, finder methods, destructors, and business methods. Implementations based on the Enterprise JavaBean specification are disclosed for three illustrative embodiments of the present invention. The illustrative embodiments of the present invention can also be implemented in accordance with object persistence mechanisms other than Enterprise JavaBeans.

FIELD OF THE INVENTION

The present invention relates to software in general, and, more particularly, to the generation of persistent objects that have mutable keys.

BACKGROUND OF THE INVENTION

Object persistence is a mechanism by which an object instance that resides in volatile memory (e.g., random-access memory [RAM], etc.) is mapped to a database, thereby providing permanent storage of the object instance's data. For example, if a source program creates and instantiates a persistent employee object instance, the data associated with the object instance is automatically stored in a database, without any explicit programming. As a result, if a hardware failure were to occur during the execution of a program that processes employee records, the most recent data for the employees would automatically be retained. Object persistence thus provides a mechanism for the permanent storage of data.

Object persistence also provides a mechanism for mapping an object instance's fields to a database, thereby enabling a programmer to (i) retrieve object information from a database without writing explicit database-handling code, and (ii) manipulate objects without having to constantly save changes back to the database. When persistent objects are mapped to a relational database, the mapping mechanism is referred to as object-relational mapping.

FIG. 1 depicts an illustrative object-relational mapping between object class 100 and database schema 110, in accordance with the prior art.

Object class 100 is a class named User that comprises six fields: ssn, lastName, firstName, birthdate, zipCode, and gender. As indicated by the underlined bold typeface, field ssn, which corresponds to social security number, is the key for object class 100 (i.e., each instance of User is uniquely identified by its ssn value).

Database schema 110 is a relation that comprises six attributes: Last, First, SSN (the schema key), Zip, Sex, and DOB.

The dotted arrows in FIG. 1 indicate the object-relational mapping between fields of object class 100 and attributes of database schema 110. As will be appreciated by those skilled in the art, a complete specification of object class 100 and database schema 110 would include data type information for the fields and attributes.

FIG. 2 depicts illustrative object instances 200-1 and 200-2, and illustrative database table 210 in accordance with the prior art.

Object instances 200-1 and 200-2, named user1 and user2, respectively, are instances of object class 100.

Database table 210 is a table in accordance with database schema 110. As shown in FIG. 2, database table 210 comprises rows 220-1 through 220-N, where N is a positive integer.

The arrows in FIG. 2 indicate illustrative object-relational mappings between database table 210 and object instances 200-1 and 200-2. In particular, object instance 200-1 is mapped to table row 220-2, and object instance 200-2 is mapped to table row 220-N, in accordance with the object-relational mapping of FIG. 1. The mapping between an object instance and a table row indicates that either:

-   -   (i) the object instance was created (e.g., by a constructor,         factory method, etc.) and its field values were then         automatically persisted in the table row; or     -   (ii) the object instance was instantiated with the pre-existing         attribute values of the table row.         In case (ii), the object instance is instantiated by invoking a         finder method that:     -   (a) takes the value of a key (in this case, a social security         number) as an argument, and     -   (b) instantiates the fields of the object instance with the         attribute values of the table row.

Enterprise JavaBeans is a specification from Sun Microsystems® for both object persistence and transaction processing. In particular, the Enterprise JavaBean (EJB) specification defines entity beans, which are persistent objects that are mapped to a relational database, and session beans, which are used to process transactions and are not persistent.

Entity Beans have at least one primary key that uniquely identifies each bean instance. The primary key can consist of a single field (e.g., social security number, etc.), or a plurality of fields. As an example of the latter, an entity bean for storing sales records might use the social security number of the sales agent in combination with the date/time of the sale as the primary key.

In accordance with the Enterprise JavaBean (EJB) specification, primary keys are immutable—i.e., their value must be specified when an entity bean instance is created, and their value cannot change during the life of the entity bean instance. Entity bean fields that do not belong to a primary key, in contrast, are mutable—i.e., their value can change during the life of the entity bean instance, and they do not have to be initialized when the entity bean instance is created.

SUMMARY OF THE INVENTION

In some situations it would be advantageous to have an entity Enterprise JavaBean (or another kind of persistent object) with a primary key that is mutable. For example, consider an application that monitors a set of users and their login status on various media servers such as email, instant messaging, voice mail, video, and audio-conferencing servers. The email server identifies a particular user U by his or her email address; the audio-conferencing server identifies user U by his or her telephone number; and so on.

In such an application, it would be natural to have a User entity bean that has a first primary key field for the user's email address, a second primary key field for the user's telephone number, etc., and to have the media servers report the login status of users to the User entity beans. The problem, however, is that the set of identifying information for a user can change over time, and typically only a subset of this information is known initially. For example, a user might first log in to an email server, ten minutes later log in to an audio-conferencing server, five minutes later log out of the email server, and so on. However, because entity JavaBean primary keys are immutable, the user's log-in information for all possible media servers would have to be specified as soon as the user logged into any one of the media servers. Furthermore, the User entity bean could not reflect changes in the user's log-in status over time.

The present invention addresses this problem via a mechanism that enables method invocation of objects with persistent data and a mutable key. The methods that can be invoked include get methods, set methods, unset methods, finder methods, destructors, and business methods. Implementations are disclosed for three illustrative embodiments based on the Enterprise JavaBean specification. The illustrative embodiments can also be implemented in accordance with object persistence mechanisms other than Enterprise JavaBeans.

The illustrative embodiment comprises: invoking a method that accesses a mutable key for a persistent object instance.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts an illustrative object-relational mapping, in accordance with the prior art.

FIG. 2 depicts two illustrative object instances of object class 100, as shown in FIG. 1, and an illustrative database table corresponding to database schema 110, as shown in FIG. 1, in accordance with the prior art.

FIG. 3 depicts three illustrative object classes, in accordance with the first illustrative embodiment of the present invention.

FIG. 4 depicts illustrative object-relational mappings for classes 301 and 302, as shown in FIG. 3, in accordance with the first illustrative embodiment of the present invention.

FIG. 5 depicts object instances of class 300, 301, and 302 after the execution of illustrative source code 503, in accordance with the first illustrative embodiment of the present invention.

FIG. 6 depicts object instances 500, 501-1, and 502, as shown in FIG. 5, after the execution of illustrative source code 603, in accordance with the first illustrative embodiment of the present invention.

FIG. 7 depicts object instances 500, 501-1, 501-2, and 502 after the execution of illustrative source code 703, in accordance with the first illustrative embodiment of the present invention.

FIG. 8 depicts object instances 500, 501-1, 501-2, 501-3, and 502 after the execution of illustrative source code 803, in accordance with the first illustrative embodiment of the present invention.

FIG. 9 depicts three illustrative object classes, in accordance with the second illustrative embodiment of the present invention.

FIG. 10 depicts object instances of class 300, 901, and 302 after the execution of illustrative source code 1003, in accordance with the second illustrative embodiment of the present invention.

FIG. 11 depicts object instances 1000 and 1002, as shown in FIG. 10, and new object instance 1001-2 after the execution of illustrative source code 1103, in accordance with the second illustrative embodiment of the present invention.

FIG. 12 depicts object instances 1000 and 1002 and new object instance 1001-3 after the execution of illustrative source code 1203, in accordance with the second illustrative embodiment of the present invention.

FIG. 13 depicts three illustrative object classes, in accordance with the third illustrative embodiment of the present invention.

FIG. 14 depicts object instances of class 1300, 901, and 302 after the execution of illustrative source code 1403, in accordance with the third illustrative embodiment of the present invention.

FIG. 15 depicts object instances 1400 and 1402, as shown in FIG. 14, and new object instance 1401-2 after the execution of illustrative source code 1503, in accordance with the third illustrative embodiment of the present invention.

FIG. 16 depicts object instances 1400 and 1402 and new object instance 1401-3 after the execution of illustrative source code 1603, in accordance with the third illustrative embodiment of the present invention.

FIG. 17 depicts object instances 1400 and 1402 and new object instance 1401-4 after the execution of illustrative source code 1703, in accordance with the third illustrative embodiment of the present invention.

FIG. 18 depicts object instances 1400 and 1402 and new object instance 1401-5 after the execution of illustrative source code 1803, in accordance with the third illustrative embodiment of the present invention.

FIG. 19 depicts object instances 1400 and 1402 and new object instance 1401-6 after the execution of illustrative source code 1903, in accordance with the third illustrative embodiment of the present invention.

DETAILED DESCRIPTION

The terms appearing below are given the following definitions for use in this Description and the appended claims.

For the purposes of the specification and claims, the term “persistent object instance” is an object instance that is mapped to a record in a persistent store. The mapping might be managed by one or more methods of the object instance, or might be managed automatically by a separate persistence mechanism. An Enterprise JavaBeans entity bean instance is an example of a persistent object instance.

For the purposes of the specification and claims, the term “persistent field” is an object field whose value is mirrored in a persistent store (e.g., a database, etc.) without explicit programming by the developer who created the object or the class to which the object belongs. A persistent field might belong to a non-persistent object instance, such as a field of a regular Java class, as well as to a persistent object instance.

For the purposes of the specification and claims, the term “key” is a datum, or a collection of data, that uniquely identifies an entity. Examples of keys include an Enterprise JavaBean primary key, a key of a table in a relational database, and so forth.

The illustrative embodiments of the present invention, described below and with respect to FIGS. 3 through 19, are disclosed in the context of Enterprise JavaBeans; however, it will be clear to those skilled in the art how to make and use alternative embodiments that are based on other object persistence mechanisms.

FIG. 3 depicts three illustrative object classes, in accordance with the first illustrative embodiment of the present invention.

Object class 300 is named User and comprises eight fields: ssn (the key), lastName, firstName, birthdate, zipCode, gender, emailAddr, and phoneNum. In accordance with the first illustrative embodiment, object class 300 is a regular Java class. However, it will be clear to those skilled in the art how to make and use alternative embodiments in which class 300 is a session Enterprise JavaBean, or an inner class of a Java servlet, or some other kind of class.

Object class 301 is an entity bean class (i.e., a class that implements interface javax.ejb.EntityBean and has persistent instances) named UserAliasBean that comprises two fields: immutable key alias, and foreignKey.

Object class 302 is an entity bean class named UserTargetBean that comprises six fields: immutable key internalKey, whose values are automatically generated by the relational database management system; lastName; firstName; birthdate; zipCode; and gender.

As depicted by the arrows in FIG. 3, object classes 300, 301, and 302, are related as follows: ssn, emailAddr, and phoneNum of User 300 relate to alias of UserAliasBean 301; and foreignKey of UserAliasBean 301 relates to UserTargetBean 302.

FIG. 4 depicts illustrative object-relational mappings for classes 301 and 302, in accordance with the first illustrative embodiment of the present invention. As depicted by the dotted arrows, the fields of class 301 are mapped to attributes of two relational database schemas: schema 410 and schema 420.

FIG. 5 depicts object instances of class 300, 301, and 302 and illustrative source code 503 and 504, in accordance with the first illustrative embodiment of the present invention. Object instances 500, 501-1, and 502 are instances of class 300, 301, and 302, respectively, that are created as a result of the execution of illustrative source code 503. As shown in FIG. 5, illustrative source code 503 creates object instance 500 via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code 503 might instead create object instance 500 via a factory pattern (e.g., when object instance 500 is a session Enterprise JavaBean, etc.).

FIG. 5 also depicts illustrative source code 504, which comprises an illustrative implementation of the User( ) constructor. This implementation:

-   -   takes a String argument that corresponds to social security         number and copies the argument into object instance 500's field         ssn;     -   creates UserAlias bean 501-1, whose alias is the social security         number;     -   creates UserTarget bean 502; and     -   sets the value of the foreign key of UserAlias bean 501-1 to the         internal key of UserTarget bean 502.

FIG. 6 depicts object instances 500, 501-1, and 502 after the execution of illustrative source code 603, in accordance with the first illustrative embodiment of the present invention. Illustrative source code 603 is a Java statement that invokes a method setFirstName( ) of object instance 500 with the String argument “John”.

FIG. 6 also depicts illustrative source code 604, which comprises an illustrative implementation of method setFirstName( ). This implementation:

-   -   takes a String argument and copies the argument into object         instance 500's field firstName; and     -   invokes UserAlias bean 502's setFirstName( ) method with the         String argument.

FIG. 7 depicts object instances 500, 501-1, and 502, as well as a new object instance 501-2, after the execution of illustrative source code 703, in accordance with the first illustrative embodiment of the present invention. Object instance 501-2 is an instance of class 301 that is created as a result of the execution of illustrative source code 703. Illustrative source code 802 is a Java statement that invokes a method setEmailAddr( ) of object instance 500 with the String argument “john52@aol.com”.

FIG. 7 also depicts illustrative source code 704, which comprises an illustrative implementation of method setEmailAddr( ). This implementation:

-   -   takes a String argument and copies the argument into object         instance 500's field emailAddr;     -   creates UserAlias bean 501-2, whose alias is the email address;     -   sets the value of the foreign key of UserAlias bean 501-2 to the         internal key of UserTarget bean 502.

FIG. 8 depicts object instances 500, 501-1, 501-2, and 502, as well as a new object instance 501-3, after the execution of illustrative source code 803, in accordance with the first illustrative embodiment of the present invention. Object instance 501-3 is an instance of class 301 that is created as a result of the execution of illustrative source code 803. Illustrative source code 803 is a Java statement that invokes a method setPhoneNum( ) of object instance 500 with the String argument “555-555-5555”.

FIG. 8 also depicts illustrative source code 804, which comprises an illustrative implementation of method setPhoneNum( ). This implementation:

-   -   takes a String argument and copies the argument into object         instance 500's field phoneNum;     -   creates UserAlias bean 501-3, whose alias is the phone number;     -   sets the value of the foreign key of UserAlias bean 501-3 to the         internal key of UserTarget bean 502.

In accordance with the first illustrative embodiment, class 300 provides three finder methods for finding instances of class 300 based on the value of a key:

-   -   static User findBySsn(String ssn)     -   static User findByEmailAddress(String emailAddr)     -   static User findByPhoneNumber(String phoneNum)         (The keyword “static” indicates that the methods belong to class         300, rather than instances of class 300). Each of the finder         methods above invokes the EJB finder method of UserAliasBean         with the specified key value as argument, and UserAliasBean's         EJB finder method in turn invokes the EJB finder method of         UserTargetBean with the foreignKey value as argument. A new User         instance can then be created and instantiated with the data from         the retrieved UserAliasBean and UserTargetBean.

As will be appreciated by those skilled in the art, class 300 can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class 300.

As will further be appreciated by those skilled in the art, in accordance with the first illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class 300 is defined in a programming language that supports destructors (e.g., C++, etc.), class 300 might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class 300 might have unset methods (e.g., unsetEmailAddr( ), etc.) that

-   -   (a) determine the number N of associated instances of class 301;         and     -   (b) when N>1:         -   destroy the instance of class 301 associated with the             particular field (e.g., field emailAddr for method             unsetEemailAddr( ), etc.), and         -   clear the value of the particular field in the instance of             class 300;     -   otherwise (N=1):         -   identify the single associated instance of class 301,         -   identify the single associated instance of class 302,         -   destroy the instance of class 302,         -   destroy the instance of class 301,         -   clear the value of the particular field in the instance of             class 300, and         -   mark the instance of class 300 as ready for garbage             collection.

As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class 302 and 301 by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class 300 to have both a destructor and one or more unset methods.

FIG. 9 depicts three illustrative object classes, in accordance with the second illustrative embodiment of the present invention.

Object classes 300 and 302 are carried over from the first illustrative embodiment.

Object class 901 is an entity bean class named UserAliasesBean that is similar to class 301 (UserAliasBean) except that its key field, named aliases instead of alias, is a set that is capable of storing a plurality of aliases (i.e., any two or all three of the user's social security number, email address, and phone number).

FIG. 10 depicts object instances of class 300, 901, and 302 and illustrative source code 1003 and 1004, in accordance with the second illustrative embodiment of the present invention. Object instances 1000, 1001-1, and 1002 are instances of class 300, 901, and 302, respectively, that are created as a result of the execution of illustrative source code 1003. As shown in FIG. 10, illustrative source code 1003 creates object instance 1000 via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code 1003 might instead create object instance 1000 via a factory pattern (e.g., when object instance 1000 is a session Enterprise JavaBean, etc.).

FIG. 10 also depicts illustrative source code 1004, which comprises an illustrative implementation of the User( ) constructor in accordance with the second illustrative embodiment. This implementation:

-   -   takes a String argument that corresponds to social security         number, and copies the argument into object instance 1000's         field ssn;     -   creates UserAliases bean 1001-1 with its aliases field         initialized to a singleton containing the social security         number;     -   creates UserTarget bean 1002; and     -   sets the value of the foreign key of UserAliases bean 1001-1 to         the internal key of UserTarget bean 1002.

FIG. 11 depicts object instances 1000 and 1002 and new object instance 1001-2 after the execution of illustrative source 1103, in accordance with the second illustrative embodiment of the present invention. Illustrative source code 1103 is a Java statement that invokes a method setEmailAddr( ) of object instance 1000 with the String argument “john52@aol.com”.

FIG. 11 also depicts illustrative source code 1104, which comprises an illustrative implementation of method setEmailAddr( ) of object instance 1000. This implementation:

-   -   takes a String argument and copies the argument into object         instance 1000's field emailAddr;     -   invokes UserAliases bean 1001-1's setEemailAddr( ) method with         the String argument, which creates a new UserAliases bean 1001-2         (see below);     -   sets variable temp to point to UserAliases bean 1001-2;     -   deletes the EJB (and its corresponding database record)         currently referenced by variable u1aliases (i.e., bean 1001-1)         and     -   sets variable u1aliases to point to new UserAliases bean 1001-2.

FIG. 11 further depicts illustrative source code 1105, which comprises an illustrative implementation of method setEmailAddr( ) of object instance 1001-1. This implementation:

-   -   takes a String argument a;     -   creates an instance s of a class AliasSet that is a subclass of         Set with additional methods for manipulating social security         numbers, email addresses, and phone numbers;     -   initializes the value of s to the set of aliases of object         instance 1001-1;     -   adds a to s (or if s already had an email address, replaces the         old address with a);     -   creates a new UserAlias bean 1001-2 (referred to locally as x)         with field aliases set to s;     -   sets the foreign key of bean 1001-2 to the foreign key of bean         1001-1; and     -   returns new UserAlias bean 1001-2.

FIG. 12 depicts object instances 1000 and 1002 and new object instance 1001-3 after the execution of illustrative source code 1203, in accordance with the second illustrative embodiment of the present invention.

Illustrative source code 1203 is a Java statement that invokes a method setPhoneNum( ) of object instance 1000 with the String argument “555-555-5555”.

FIG. 12 also depicts illustrative source code 1204, which comprises an illustrative implementation of method setPhoneNum( ) of object instance 1000. This implementation:

-   -   takes a String argument and copies the argument into object         instance 1000's field phoneNum; and     -   invokes UserAliases bean 1001-2's setPhoneNum( ) method with the         String argument, which creates a new UserAliases bean 1001-3         (see below);     -   sets variable temp to point to UserAliases bean 1001-3;     -   deletes the EJB (and its corresponding database record)         currently referenced by variable u1aliases (i.e., bean 1001-2)         and     -   sets variable u1aliases to point to new UserAliases bean 1001-3.

FIG. 12 further depicts illustrative source code 1205, which comprises an illustrative implementation of method setPhoneNum( ) of object instance 1001-2. This implementation:

-   -   takes a String argument a;     -   creates an instance s of class AliasSet;     -   initializes the value of s to the set of aliases of object         instance 1001-2;     -   adds a to s (or if s already had a phone number, replaces the         old phone number with a);     -   creates a new UserAlias bean 1001-3 (referred to locally as x)         with field aliases set to s;     -   sets the foreign key of bean 1001-3 to the foreign key of bean         1001-2; and     -   returns UserAlias bean 1001-3.

In accordance with the second illustrative embodiment, class 500 provides the same three finder methods as class 300 of the first illustrative embodiment:

-   -   static User findBySsn(String ssn)     -   static User findByEmailAddress(String emailAddr)     -   static User findByPhoneNumber(String phoneNum)         Each of these finder methods works the same way as in the first         illustrative embodiment (i.e., by invoking the EJB finder method         of UserAliasBean with the specified key value as argument, which         in turn invokes the EJB finder method of UserTargetBean with the         foreignKey value as argument, and creating a new User instance         based on the retrieved UserAliasBean and UserTargetBean.

As will be appreciated by those skilled in the art, class 300 can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class 300.

As will further be appreciated by those skilled in the art, in accordance with the second illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class 300 is defined in a programming language that supports destructors (e.g., C++, etc.), class 300 might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class 300 might have unset methods (e.g., unsetEmailAddr( ), etc.) that

-   -   (a) navigate to field aliases of the single associated instance         of class 901; and     -   (b) when aliases has two or more elements:         -   delete the appropriate element from aliases, and         -   clear the value of the appropriate field in the instance of             class 300;     -   otherwise (aliases has one element):         -   identify the single associated instance of class 302,         -   destroy the instance of class 302,         -   destroy the instance of class 901,         -   clear the value of the particular field in the instance of             class 300, and         -   mark the instance of class 300 as ready for garbage             collection.

As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class 302 and 901 by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class 300 to have both a destructor and one or more unset methods.

FIG. 13 depicts three illustrative object classes, in accordance with the third illustrative embodiment of the present invention.

Object classes 901 and 302 are carried over from the second illustrative embodiment.

Object class 1300 is named User and is similar to class 300 (also named User), except that class 300's mutable key fields ssn, emailAddr, and phoneNum have been replaced with a single mutable key field aliases that is capable of storing a plurality of aliases. In the third illustrative embodiment, not only is the key field aliases in both classes 1300 and 901 capable of storing a social security number, an email address, and a phone number, but they are also capable of storing multiple phone numbers and email addresses (e.g., office and mobile phone numbers, personal and business email addresses, etc.), where each of the phone numbers and email addresses uniquely identifies an object instance.

In accordance with the third illustrative embodiment, object class 1300 is, like class 300, a regular Java class. However, it will be clear to those skilled in the art how to make and use alternative embodiments in which class 1300 is a session Enterprise JavaBean, or an inner class of a Java servlet, or some other kind of class.

FIG. 14 depicts object instances of class 1300, 901 and 302 and illustrative source code 1403 and 1404, in accordance with the third illustrative embodiment of the present invention. Object instances 1400, 1401-1, and 1402 are instances of class 1300, 901, and 302, respectively, that are created as a result of the execution of illustrative source code 1403. As shown in FIG. 14, illustrative source code 1403 creates object instance 1400 via a conventional Java constructor. It will be appreciated by those skilled in the art that in some other embodiments of the present invention, source code 1403 might instead create object instance 1000 via a factory pattern (e.g., when object instance 1400 is a session Enterprise JavaBean, etc.).

FIG. 14 also depicts illustrative source code 1404, which comprises an illustrative implementation of the User( ) constructor in accordance with the third illustrative embodiment. This implementation:

-   -   takes a String argument that corresponds to social security         number;     -   adds the argument to object instance 1400's field aliases, which         was initialized to the empty set;     -   creates UserAliases bean 1401-1 with its aliases field         initialized to a singleton containing the social security         number;     -   creates UserTarget bean 1402; and     -   sets the value of the foreign key of UserAliases bean 1001-1 to         the internal key of UserTarget bean 1002.

FIG. 15 depicts object instances 1400 and 1402 and new object instance 1401-2 after the execution of illustrative source code 1403, in accordance with the third illustrative embodiment of the present invention. Illustrative source code 1503 is a Java statement that invokes a method addAlias( ) of object instance 1400 with the String argument “john52@aol.com”.

FIG. 15 also depicts illustrative source code 1504, which comprises an illustrative implementation of method addAlias( ) of object instance 1400. This implementation:

-   -   takes a String argument and adds the argument to object instance         1400's field aliases;     -   invokes UserAliases bean 1401-1's addAlias( ) method with the         String argument, which creates a new UserAliases bean 1401-2         (see below);     -   sets variable temp to point to UserAliases bean 1401-2;     -   deletes the EJB (and its corresponding database record)         currently referenced by variable u1aliases (i.e., bean 1401-1)         and     -   sets variable u1aliases to point to new UserAliases bean 1401-2.

FIG. 15 further depicts illustrative source code 1505, which comprises an illustrative implementation of method addAlias( ) of object instance 1401-1. This implementation:

-   -   takes a String argument a;     -   sets variable s to the union of         -   (i) the current aliases of object instance 1401-1, and         -   (ii) set {a};     -   creates a new UserAlias bean 1401-2 (referred to locally as x)         with field aliases set to s;     -   sets the foreign key of bean 1401-2 to the foreign key of bean         1401-1; and     -   returns new UserAlias bean 1401-2.

FIG. 16 depicts object instances 1400 and 1402 and new object instance 1401-3 after the execution of illustrative source code 1603, in accordance with the third illustrative embodiment of the present invention. Illustrative source code 1603 invokes method addAlias( ) of object instance 1400 with the String argument “555-555-5555”, which executes in similar fashion as source code 1503.

FIG. 17 depicts object instances 1400 and 1402 and new object instance 1401-4 after the execution of illustrative source code 1703, in accordance with the third illustrative embodiment of the present invention. Illustrative source code 1703 is a Java statement that invokes a method changeAlias( ) of object instance 1400 with the String arguments “john52@aol.com” and “jcarter@nih.gov”.

FIG. 17 also depicts illustrative source code 1704, which comprises an illustrative implementation of method changeAlias( ) of object instance 1400. This implementation:

-   -   takes String arguments a1 and a2;     -   deletes a1 from object instance 1400's field aliases (if a1 is         not an alias of object instance 1400, then an         AliasNotFoundException is thrown);     -   adds a2 to object instance 1400's field aliases;     -   invokes UserAliases bean 1401-3's changeAlias( ) method with         arguments a1 and a2, which creates a new UserAliases bean 1401-4         (see below);     -   sets variable temp to point to UserAliases bean 1401-4;     -   deletes the EJB (and its corresponding database record)         currently referenced by variable u1aliases (i.e., bean 1401-3)         and     -   sets variable u1aliases to point to new UserAliases bean 1401-4.

FIG. 17 further depicts illustrative source code 1705, which comprises an illustrative implementation of method changeAlias( ) of object instance 1401-3. This implementation:

-   -   takes String arguments a1 and a2;     -   initializes variable s to the set of aliases of object instance         1401-3;     -   deletes string a1 from set s;     -   adds string a2 to set s;     -   creates a new UserAlias bean 1401-4 (referred to locally as x)         with field aliases set to s;     -   sets the foreign key of bean 1401-4 to the foreign key of bean         1401-3; and     -   returns new UserAlias bean 1401-4.

FIG. 18 depicts object instances 1400 and 1402 and new object instance 1401-5 after the execution of illustrative source code 1803, in accordance with the third illustrative embodiment of the present invention. Illustrative source code 1803 is a Java statement that invokes a method deleteAlias( ) of object instance 1400 with a String argument “555-555-5555”.

FIG. 18 also depicts illustrative source code 1804, which comprises an illustrative implementation of method deleteAlias( ) of object instance 1400. This implementation:

-   -   takes a String argument a;     -   deletes a from object instance 1400's field aliases (if a is not         an alias of object instance 1400, then an AliasNotFoundException         is thrown);     -   invokes UserAliases bean 1401-4's deleteAlias( ) method with         argument a, which creates a new UserAliases bean 1401-5 (see         below);     -   sets variable temp to point to UserAliases bean 1401-5;     -   deletes the EJB (and its corresponding database record)         currently referenced by variable u1aliases (i.e., bean 1401-4)         and     -   sets variable u1aliases to point to new UserAliases bean 1401-5.

FIG. 18 further depicts illustrative source code 1805, which comprises an illustrative implementation of method deleteAlias( ) of object instance 1401-4. This implementation:

-   -   takes String argument a;     -   initializes variable s to the set of aliases of object instance         1401-4;     -   deletes string a from set s;     -   creates a new UserAlias bean 1401-5 (referred to locally as x)         with field aliases set to s;     -   sets the foreign key of bean 1401-5 to the foreign key of bean         1401-4; and     -   returns new UserAlias bean 1401-5.

FIG. 19 depicts object instances 1400 and 1402 and new object instance 1401-6 after the execution of illustrative source code 1603, in accordance with the third illustrative embodiment of the present invention. Illustrative source code 1603 invokes method addAlias( ) of object instance 1400 with the String argument “DNA@gmail.com”, which executes in similar fashion as source code 1503 and 1603. Thus in the third illustrative embodiment of the present invention, it is possible for a user to have a plurality of email address aliases. It will be clear to those skilled in the art how to augment the third illustrative embodiment to allow only one social security number alias per user, while still permitting multiple aliases for other types of information (e.g., email addresses, phone numbers, etc.).

In some operating environments the third illustrative embodiment enjoys a performance advantage over the first and second illustrative embodiments. However, the third illustrative embodiment has the following disadvantage: an implementation for finder methods based on a single key value (i.e., a social security number or an email address or a phone number) cannot simply invoke the EJB finder method of UserAliases, as is done in the first and second illustrative embodiments. For example, in accordance with the third illustrative embodiment, implementing such finder methods for User (e.g., findBySsn, findByEmailAddress, findByPhoneNumber, etc.) requires one or more queries to determine whether a given key value is contained in the aliases field of UserAliases bean instances.

As will be appreciated by those skilled in the art, class 1300 can also have data accessor methods (i.e., get methods) and “business” methods—as object classes typically do—and it will be clear to those skilled in the art, after reading this disclosure, how to make and use such embodiments of class 1300.

As will further be appreciated by those skilled in the art, in accordance with the third illustrative embodiment there is a variety of options for handling the destruction of object instances (or “garbage collection”). In some embodiments in which class 1300 is defined in a programming language that supports destructors (e.g., C++, etc.), class 1300 might have a destructor for destroying instances of the class. In some other embodiments—including those that use a programming language with no destructors (e.g., Java, etc.)—class 1300 might have unset methods (e.g., unsetEmailAddr( ), etc.) that

-   -   (a) navigate to field aliases of the single associated instance         of class 901; and     -   (b) when aliases has two or more elements:         -   delete the appropriate element from aliases, and         -   delete the same element from field aliases of the instance             of class 1300;     -   otherwise (aliases has one element):         -   identify the single associated instance of class 302,         -   destroy the instance of class 302,         -   destroy the instance of class 901,         -   set field aliases of the instance of class 1300 to the empty             set, and         -   mark the instance of class 1300 as ready for garbage             collection.

As will be appreciated by those skilled in the art, in some embodiments, the destruction of instances of class 302 and 901 by an unset method might be subject to object locking via a transaction or some other means of concurrency control. Furthermore, some embodiments of the present invention that use a programming language with support for destructors might define class 1300 to have both a destructor and one or more unset methods.

As will also be appreciated by those skilled in the art, in some embodiments of the present invention—whether in accordance with the first, second, or third illustrative embodiments—it might be advantageous for the “behind-the-scenes” Enterprise JavaBean classes and instances (e.g., classes 301 and 302 and their instances, etc.), as well as the code for creating and manipulating these classes and instances, to be automatically generated (e.g., by an application server, by an integrated development environment, etc.) rather than hand-coded by a developer. In such embodiments, a developer might create the “front-end” classes and instances (e.g., class 300 and its instances, etc.) and not even be aware of the existence of the behind-the-scenes classes and instances that are automatically generated.

It is to be understood that the above-described embodiments are merely illustrative of the present invention and that many variations of the above-described embodiments can be devised by those skilled in the art without departing from the scope of the invention. For example, in this Specification, numerous specific details are provided in order to provide a thorough description and understanding of the illustrative embodiments of the present invention. Those skilled in the art will recognize, however, that the invention can be practiced without one or more of those details, or with other methods, materials, components, etc.

Furthermore, in some instances, well-known structures, materials, or operations are not shown or described in detail to avoid obscuring aspects of the illustrative embodiments. It is understood that the various embodiments shown in the Figures are illustrative, and are not necessarily drawn to scale. Reference throughout the specification to “one embodiment” or “an embodiment” or “some embodiments” means that a particular feature, structure, material, or characteristic described in connection with the embodiment(s) is included in at least one embodiment of the present invention, but not necessarily all embodiments. Consequently, the appearances of the phrase “in one embodiment,” “in an embodiment,” or “in some embodiments” in various places throughout the Specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments. It is therefore intended that such variations be included within the scope of the following claims and their equivalents. 

What is claimed is:
 1. A method comprising: receiving information associated with a non-persistent object instance, the non-persistent object instance comprising: a persistent field having a first value; a mutable primary key used to access a relational database, the mutable primary key comprising data that uniquely identifies the non-persistent object instance, the data having a mutable value that can change during a life of the non-persistent object instance; and a configuration to mirror the first value to the relational database via a first persistent object instance and a second persistent object instance, wherein the first persistent object instance comprises a first immutable primary key associated with the mutable primary key and a foreign key, and wherein the second persistent object instance comprises a second immutable key, associated with the foreign key, and a second value that mirrors the first value and further is mirrored to the relational database; accessing, based on the information, the relational database, to yield relational database information; and adding an alias key to the non-persistent object instance based on the relational database information, wherein both the alias key and the mutable primary key can be used to access the relational database, and wherein the alias key and the mutable primary key are distinct types of identifiers of the non-persistent object instance.
 2. The method of claim 1, further comprising setting a value of the mutable primary key.
 3. The method of claim 1, wherein the mutable primary key has a plurality of different values simultaneously, the method further comprising at least one of: adding a new value to the mutable primary key, deleting an existing value of the mutable primary key, and changing one of the plurality of different values.
 4. The method of claim 1, further comprising at least one of: generating one of the first and second persistent object instances, and deleting one of the first and second persistent object instances.
 5. The method of claim 1, wherein the types of identifiers comprise a social security number, an email address, and a phone number.
 6. The method of claim 5, wherein the phone number in the types of identifiers further comprises an office phone number and a personal phone number, and wherein each of the office phone number and the personal phone number, when used as one of the alias key and the mutable primary key, uniquely identifies the non-persistent object instance.
 7. The method of claim 6, wherein the email address in the types of identifiers further comprises a personal email address and a business email address, and wherein each of the personal email address and the business email address, when used as one of the alias key and the mutable primary key, uniquely identifies the non-persistent object instance.
 8. A system comprising: a processor; and a non-transitory computer-readable storage medium having stored therein instructions which, when executed by the processor, cause the processor to perform operations comprising: receiving information associated with an object, the object generated by a program and defined by an object class, the object comprising: a persistent field having a first value; a mutable primary key used to access a relational database, the mutable primary key comprising data that uniquely identifies the object, the data having a mutable value that can change during a life of the object; and a configuration to mirror the first value to the relational database via a first persistent object instance and a second persistent object instance, wherein the first persistent object instance comprises a first immutable primary key associated with the mutable primary key and a foreign key, and wherein the second persistent object instance comprises a second immutable key, associated with the foreign key, and a second value configured to mirror the first value and further configured to be mirrored to the relational database; accessing, based on the information, the relational database, to yield relational database information; and adding an alias key to the object based on the relational database information, wherein both the alias key and the mutable primary key can be used to access the relational database, and wherein the alias key and the mutable primary key are distinct types of identifiers of the object.
 9. The system of claim 8, wherein one of the first and second persistent object instances belongs to an object class that implements an Enterprise JavaBean interface.
 10. The system of claim 8, wherein the operations further comprise setting a value of the mutable primary key.
 11. The system of claim 8, wherein the mutable primary key has a plurality of different values simultaneously, and wherein operations further comprise at least one of: adding a new value to the mutable primary key; deleting an existing value of the mutable primary key; and changing one of the plurality of different values.
 12. The system of claim 11, wherein the second persistent object instance comprises a data structure, and wherein the operations further comprise at least one of: adding at least one value of the mutable primary key to the data structure; deleting at least one value of the mutable primary key from the data structure; and changing at least one value of the mutable primary key in the data structure.
 13. The system of claim 8, wherein the operations further comprise at least one of: generating one of the first and second persistent object instances, and deleting one of the first and second persistent object instances.
 14. A device comprising: a processor; and a non-transitory computer-readable storage medium having stored therein instructions which, when executed by the processor, cause the processor to perform operations comprising: receiving information associated with an object, the object generated by a program and defined by an object class, the object comprising: a persistent field having a first value; a mutable primary key used to access a relational database, the mutable primary key comprising data that uniquely identifies the object, the data having a mutable value that can change during a life of the object; and a configuration to mirror the first value to the relational database via a first persistent object instance and a second persistent object instance, wherein the first persistent object instance comprises a first immutable primary key associated with the mutable primary key and a foreign key, and wherein the second persistent object instance comprises a second immutable key, associated with the foreign key, and a second value configured to mirror the first value and further configured to be mirrored to the relational database; accessing, based on the information, the relational database, to yield relational database information; and adding an alias key to the object based on the relational database information, wherein both the alias key and the mutable primary key can be used to access the relational database, and wherein the alias key and the mutable primary key are distinct types of identifiers of the object.
 15. The device of claim 14, wherein one of the first and second persistent object instances belongs to an object class that implements an Enterprise JavaBean interface.
 16. The device of claim 14, wherein the operations further comprise finding, based on the value of the mutable primary key, the first persistent object instance, the second persistent object instance, or another persistent object instance. 